package com.kongmou.Springmvc.controller;

import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class UploadController {

	@RequestMapping("/upload")
	public @ResponseBody String upload(MultipartFile file) {
		try {
			IOUtils.write(file.getBytes(), new FileOutputStream("d:" + file.getOriginalFilename()));
			return "ok";
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "faild";

	}

}
